package cleancode.chapter02;

/**
 * @Description
 * @Date 2021/9/20
 * @Created by Jonathan
 */
public class SemanticProblemDemo01 {

    public void printGuessStatistics(char candidate, int count) {
        // 重构下面这一段
        /*String number;
        String verb;
        String pluralModifier;
        if (count == 0) {
            number = "no";
            verb = "are";
            pluralModifier = "s";
        } else if (count == 1) {
            number = "l";
            verb = "is";
            pluralModifier = "";
        } else {
            number = Integer.toString(count);
            verb = "are";
            pluralModifier = "s";
        }
        String guessMessage = String.format("There %s %s %s%s", verb, number, candidate, pluralModifier);
        print(guessMessage);*/
        // 重构之后的代码引入了下面这一句
        new GuessStatisticsMessage(this).print(candidate, count);
    }

    public void print(String guessMessage) {
        System.out.printf("the message is:%s", guessMessage);
    }

}
